home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / misc~1 / 5 / osspascl / dirlist.pas < prev    next >
Pascal/Delphi Source File  |  1985-11-19  |  2KB  |  69 lines

  1.  
  2. PROGRAM dir_test ;
  3.  
  4.   TYPE
  5.     fn_range = 1..14 ;
  6.     fname = PACKED ARRAY [ fn_range ] OF char ;
  7.     frec = PACKED RECORD
  8.              reserved : PACKED ARRAY [ 0..19 ] OF byte ;
  9.              resvd2 : byte ;
  10.              attrib : byte ;
  11.              time_stamp : integer ;
  12.              date_stamp : integer ;
  13.              size : long_integer ;
  14.              name : fname ;
  15.            END ;
  16.     path_name = PACKED ARRAY [ 1..80 ] OF char ;
  17.  
  18.   VAR
  19.     r : frec ;
  20.     i : fn_range ;
  21.     path_string : STRING ;
  22.     path : path_name ;
  23.  
  24.   PROCEDURE set_dta( VAR buf : frec ) ;
  25.     GEMDOS( $1a ) ;
  26.  
  27.   FUNCTION get_first( VAR path : path_name ; search_attrib :integer ):integer ;
  28.     GEMDOS( $4e ) ;
  29.  
  30.   FUNCTION get_next : integer ;
  31.     GEMDOS( $4f ) ;
  32.  
  33.   PROCEDURE show_file( VAR r : frec ) ;
  34.  
  35.     VAR
  36.       i : fn_range ;
  37.  
  38.     BEGIN
  39.       WITH r DO
  40.         BEGIN
  41.           write( attrib:2:h, ' ', time_stamp:4:h, ' ', date_stamp:4:h, ' ',
  42.                 size:8:h, ' ' ) ;
  43.           i := 1 ;
  44.           WHILE (i <= 14) AND (name[i] <> chr(0)) DO
  45.             BEGIN
  46.               write( name[i] ) ;
  47.               i := i + 1
  48.             END ;
  49.           writeln ;
  50.         END ;
  51.     END ;
  52.  
  53.   BEGIN
  54.     write( 'search path: ' ) ;
  55.     readln( path_string ) ;
  56.     FOR i := 1 TO length( path_string ) DO
  57.       path[i] := path_string[i] ;
  58.     path[ length(path_string)+1 ] := chr(0) ;
  59.     set_dta( r ) ;
  60.     IF get_first( path, 0 ) < 0 THEN
  61.       writeln( 'no files match specification!' )
  62.     ELSE
  63.       REPEAT
  64.         show_file( r ) ;
  65.       UNTIL get_next < 0 ;
  66.   END.
  67.  
  68.  
  69.